#include <iostream>
#include <queue>

using namespace std;


struct node {
    int x, y;
    bool operator<(const node& n1)const
    {
        if(y > n1.y)
        {
            return false;
        }
        else if(y == n1.y)
        {
            return x > n1.x;
        }
        return true;
    }
};

const int N = 2e6+10;
int a[N],b[N];

int main() {
    long long n, m;
    cin >> n >> m;
    priority_queue<node> q;
    
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    for (int i = 1; i <= n; i++) {
        q.push({a[i], b[i]});
    }


    // while(q.size())
    // {
    //     auto e = q.top();
    //     q.pop();
    //     cout << e.x << ' ' << e.y << endl;
    // }

    long long sum1 = 0,sum2 = 0;
    while (m--) {
        auto e = q.top();
        q.pop();
        sum1 += e.x;
        sum2 += e.y;
    }
    cout << sum1 << " " << sum2 <<endl;

    return 0;
}
// 64 位输出请用 printf("%lld")